﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/4/2009
 * Time: 1:15 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using NHibernate;
using System.Collections.Generic;
using System.Data;
using PilotFish.Model.Dao.Interface;

namespace PilotFish.Model.Dao.NHibernate
{
	/// <summary>
	/// Description of NHibernateAllergyDao.
	/// </summary>
	public class NHibernateAllergyDao : IAllergyDao
	{
		public NHibernateAllergyDao()
		{
		}
		
		public void SaveOrUpdate(Allergy allergy)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.SaveOrUpdate(allergy);
			session.Flush();
		}
		
		public void Delete(Allergy allergy)
		{
			ISession session = NHibernateHelper.OpenSession();
			session.Delete(allergy);
			session.Flush();
		}
		
		public Allergy ReadByPk(int id)
		{
			return NHibernateHelper.OpenSession().Load<Allergy>(id);
		}
		
		public IList<Allergy> FindAll()
		{
			return NHibernateHelper.OpenSession().CreateCriteria(typeof(Allergy)).List<Allergy>();
		}
	}
}
